
const path = require("path");
const nodeExternals = require("webpack-node-externals");
const { merge } = require("webpack-merge");
const config = require("./webpack.base");
/**
 * 服务端的webpack
 */
const serverConfig = {
  target: "node",
  mode: "development",
  externals: [nodeExternals()], // 规避不需要产生的代码
  entry: "./server/index.js",
  output: {
    filename: "bundle.js",
    path: path.resolve(__dirname, "build")
  },
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          "isomorphic-style-loader",
          {
            loader: 'css-loader',
            options: {
              importLoaders: 1,
              esModule: false,
              modules: {
                localIdentName: "[name]_[local]_[hash:base64:5]",
              },
            }
          }
        ]
      },
    ]
  }
}

module.exports = merge(config, serverConfig);